home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-04-03 | 12.5 KB | 522 lines | [TEXT/MPS ] |
- // IconEdit.h
- // Copyright © 1988-96 by Apple Computer, Inc. All rights reserved.
-
- #ifndef __UICONEDIT__
- #define __UICONEDIT__
-
- // MacApp
-
- #ifndef __UAPPLICATION__
- #include "UApplication.h"
- #endif
-
- #ifndef __UCOMMAND__
- #include "UCommand.h"
- #endif
-
- #ifndef __UFILEBASEDDOCUMENT__
- #include "UFileBasedDocument.h"
- #endif
-
- #ifndef __UVIEW__
- #include "UView.h"
- #endif
-
-
- // Constants
- const OSType kSignature = 'ICED'; // Application signature
- const OSType kFileType = 'ICON'; // File-type for document files created by this application
-
- // definitions for the custom apple event suite
- const OSType kAEIconEditClass = 'ICED'; // event class
-
- const OSType kAEInvertID = 'INVT'; // event IDs
- const OSType kAEZoomInID = 'ZmIn';
- const OSType kAEZoomOutID = 'ZmOt';
- const OSType kAEDrawPoints = 'DrPt';
-
- const AEKeyword keyPointList = 'kPtL';
- const AEKeyword keyErasePoints = 'kErs';
-
- // Forward references
- class TIconBitMap;
- class TIconEditView;
-
- // Classes
- // ====================================================================================
-
- class TIconEditApplication : public TApplication
- {
- MA_DECLARE_CLASS;
-
- public:
- virtual ~TIconEditApplication();
- // Destructor
-
- virtual void IIconEditApplication();
-
- virtual TDocument* DoMakeDocument(CommandNumber itsCommandNumber,
- TFile* itsFile);// Override
-
- virtual TView* MakeViewForAlienClipboard(); // Override
- // Makes a view of type TIconEditView for the Clipboard if the public desk
- // scrap contains data of type 'ICON'. Otherwise it calls INHERITED
- // MakeViewForAlienClipboard.
- };
-
- // ====================================================================================
- //old class TIconDocument : public TDocument
-
- class TIconDocument : public TFileBasedDocument //new
- {
- MA_DECLARE_CLASS;
-
- public:
- TIconDocument();
- // Constructor
-
- void IIconDocument(TFile* itsDocument);
-
- virtual ~TIconDocument();
-
- virtual void DoInitialState(); // Override
-
- virtual void DoMakeViews(Boolean forPrinting);// Override
-
- virtual void DoMenuCommand(CommandNumber aCommandNumber);
-
- virtual void DoScriptCommand(CommandNumber aCommand,
- TAppleEvent* message,
- TAppleEvent* reply);// Override
-
- virtual void DoSetupMenus(); // Override
-
- virtual void DoNeedDiskSpace(TFile* itsDocument,
- long& dataForkBytes,
- long& rsrcForkBytes);// Override
-
- virtual void DoRead(TFile* itsDocument,
- Boolean forPrinting); // Override
-
- virtual void DoWrite(TFile* itsDocument,
- Boolean makingCopy); // Override
-
- virtual void InvertIcon();
-
- inline TIconEditView* GetIconView() const
- { return fIconView; }
-
-
- virtual void ClearIcon();
-
- virtual void SetIcon(TIconBitMap* newIcon);
-
- inline TIconBitMap* ReturnBitMap() const
- { return fIconBitMap; }
-
- virtual void RedrawViews();
-
- virtual void GetSetPropertyInfo(DescType whichProperty,
- CommandNumber& cmdNum,
- Boolean& canUndo,
- Boolean& causesChange,
- TCommandHandler*& theContext);// Override
-
- virtual void SetObjectProperty(const CAEDesc& thePropertyValue,
- DescType whichProperty);// Override
-
- virtual Boolean GetObjectProperty(CAEDesc& thePropertyValue,
- DescType whichProperty,
- const CAEDesc& desiredType); // Override
-
- inline CRGBColor GetIconColor() const
- { return fColor; }
-
- virtual void SetIconColor(CRGBColor& newColor);
-
- protected:
- CRGBColor fColor; // color property of the document
- TIconBitMap* fIconBitMap; // The icon's bit map
- TIconEditView* fIconView; // a reference to the single view in this window
- };
-
-
- // ====================================================================================
-
- class TIconEditView : public TView
- {
- MA_DECLARE_CLASS;
-
- public:
- TIconEditView();
- // Constructor
-
- virtual ~TIconEditView();
- // Destructor
-
- virtual void IIconEditView(TDocument* itsDocument,
- TView* itsSuperView,
- const VPoint& itsLocation,
- short itsMagnification);
-
- virtual void DoPostCreate(TDocument* itsDocument);// Override
-
- virtual VRect CalcMinFrame(); // Override
-
- virtual Boolean ContainsClipType(ResType aType);// Override
- // Called when a view of this type is installed in the Clipboard.
- // Returns true if aType is kIconClipType (i.e. 'ICON').
-
- virtual void DoKeyEvent(TToolboxEvent* info);// Override
- // Treats the backspace the same as the Clear command.
-
- virtual void DoMenuCommand(CommandNumber aCommandNumber);// Override
-
- virtual void DoMouseCommand(VPoint& theMouse,
- TToolboxEvent* event,
- CPoint hysteresis);// Override
-
- virtual void DoSetCursor(const VPoint& localPoint,
- RgnHandle cursorRegion);// Override
-
- virtual void DoSetupMenus(); // Override
-
- virtual void Draw(const VRect& area); // Override
-
- virtual void DrawBit(VPoint theBit,
- Boolean turnBitOn,
- CRGBColor& drawingColor);
-
- Boolean PointToBit(const VPoint& thePoint,
- VPoint& iconBit);
-
- short GetMagnification() const
- { return fMagnification; }
-
- virtual void SetMagnification(short magnification);
-
- virtual void WriteToDeskScrap(); // Override
-
- protected:
- TIconDocument* fIconDocument; // Reference to the view's icon document.
- short fMagnification; // No. of times to magnify the icon.
- };
-
- // ====================================================================================
-
- class TDrawPointsAppleEvent : public TAppleEvent
- {
- MA_DECLARE_CLASS;
-
- public:
- TDrawPointsAppleEvent();
-
- virtual ~TDrawPointsAppleEvent();
- // Destructor
-
- void IDrawPointsAppleEvent(MScriptableObject* itsDirectObject,
- TIconBitMap* iconBitMapModel,
- const Boolean turnBitsOn);
- };
-
- // ====================================================================================
-
- class TDrawPointsCommand : public TCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- TDrawPointsCommand();
- // Constructor
-
- virtual ~TDrawPointsCommand();
-
- virtual void IDrawPointsCommand(TIconDocument* itsIconDocument,
- TAppleEvent* theAppleEvent);
-
- virtual void DoIt(); // Override
-
- virtual void RedoIt(); // Override
-
- virtual void UndoIt(); // Override
-
- protected:
- TIconBitMap* fSavedBitMap;
- TIconDocument* fIconDocument; // The document affected by this command.
- TDynamicArray* fPointList; // list of points to set or unset
- Boolean fErasePoints;
- };
-
- // ====================================================================================
-
- class TSetColorCommand : public TCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- TSetColorCommand();
- // Constructor
-
- virtual ~TSetColorCommand();
- // Destructor
-
- virtual void ISetColorCommand(TIconDocument* itsIconDocument,
- CRGBColor& newColor);
-
- virtual void DoIt(); // Override
-
- virtual void RedoIt(); // Override
-
- virtual void UndoIt(); // Override
-
- protected:
- CRGBColor fOldColor;
- CRGBColor fNewColor;
- };
-
-
- // ====================================================================================
-
- class TInvertCommand : public TCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- TInvertCommand();
- // Constructor
-
- virtual ~TInvertCommand();
- // Destructor
-
- virtual void IInvertCommand(TIconDocument* itsIconDocument);
-
- virtual TAppleEvent* MakeAppleEvent();
-
-
- virtual void DoIt(); // Override
-
- virtual void RedoIt(); // Override
-
- virtual void UndoIt(); // Override
-
- protected:
- TIconDocument* fIconDocument; // The document affected by this command.
- };
-
-
- // ====================================================================================
-
- class TIconDrawCommand : public TTracker
- {
- MA_DECLARE_CLASS;
-
- public:
- TIconDrawCommand();
- // Constructor
-
- virtual ~TIconDrawCommand();
-
- virtual void IIconDrawCommand(TIconEditView* itsIconEditView,
- TIconDocument* itsIconDocument,
- VPoint& theMouse);
-
- virtual void DoIt(); // Override
- // Sets the fIconDocument's icon bitmap to that of fIconBitMap by calling
- // the document's SetIcon method. Validates the edit view to avoid
- // flashing.
-
- virtual void RedoIt(); // Override
-
- virtual void TrackConstrain(TrackPhase aTrackPhase,
- const VPoint& anchorPoint,
- const VPoint& previousPoint,
- VPoint& nextPoint,
- Boolean mouseDidMove);
-
- virtual void TrackFeedback(TrackPhase aTrackPhase,
- const VPoint& anchorPoint,
- const VPoint& previousPoint,
- const VPoint& nextPoint,
- Boolean mouseDidMove,
- Boolean turnItOn);
-
- virtual TTracker* TrackMouse(TrackPhase aTrackPhase,
- VPoint& anchorPoint,
- VPoint& previousPoint,
- VPoint& nextPoint,
- Boolean mouseDidMove);
-
- virtual void UndoIt(); // Override
- // Sets the fIconDocument's icon bitmap to that of fOriginalIcon by calling
- // the document's SetIcon method.
-
- protected:
- CRGBColor fColor; // drawing color (property of fDocument)
- TIconDocument* fIconDocument; // The document affected by this command.
- TIconEditView* fIconEditView; // The view in which this command draws.
- TIconBitMap* fIconBitMap; // The icon in which drawing takes place.
- TIconBitMap* fIconBitMapModel; // Model used to generate apple events
- TIconBitMap* fOriginalIcon; // A copy of the original icon.
- Boolean fTurnBitsOn; // Whether to draw bits black or white.
- };
-
-
- // ====================================================================================
-
- class TIconEditCommand : public TCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- TIconEditCommand();
- // Constructor
-
- virtual ~TIconEditCommand();
-
- virtual void IIconEditCommand(CommandNumber itsCommandNumber,
- TIconEditView* itsIconEditView,
- TIconDocument* itsIconDocument);
- virtual void DoIt(); // Override
-
- virtual void RedoIt(); // Override
-
- virtual void UndoIt(); // Override
-
- protected:
- TIconDocument* fIconDocument; // The document affected by this command.
- TIconEditView* fIconEditView; // The view in which this command draws.
- TIconBitMap* fSavedBitMap; // Saved state for undo/redo
- };
-
-
- // ====================================================================================
-
- class TIconPasteCommand : public TCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- TIconPasteCommand();
- // Constructor
-
- virtual ~TIconPasteCommand();
-
- virtual void IIconPasteCommand(TIconEditView* itsIconEditView,
- TIconDocument* itsIconDocument);
- virtual void DoIt(); // Override
-
- virtual void UndoIt(); // Override
-
- protected:
- TIconDocument* fIconDocument; // The document affected by this command.
- TIconEditView* fIconEditView; // The view in which this command draws.
- TIconBitMap* fSavedIcon; // Temporary saved icon
- };
-
-
- // ====================================================================================
-
- class TIconBitMap : public TObject
- {
- MA_DECLARE_CLASS;
-
- public:
- TIconBitMap();
- // Constructor
-
- virtual ~TIconBitMap();
-
- virtual void IIconBitMap();
-
- virtual void SetIconBitMap(Handle theBitMap);
-
- virtual void ReadFrom(TStream* aStream); // Override
-
- virtual void WriteTo(TStream* aStream); // Override
-
- virtual void LoadFromScrap();
-
- virtual void WriteToScrap();
-
- virtual TIconBitMap* Copy();
-
- virtual void CopyDataTo(TIconBitMap* anIcon);
-
- virtual void Clear();
-
- virtual void Invert();
-
- virtual void Draw(const CRect& area,
- const CRGBColor& drawingColor);//not Override!
-
- virtual Boolean GetBit(VPoint iconBit);
-
- virtual void SetBit(VPoint iconBit,
- Boolean turnBitOn);
-
- virtual void IconBitToByteBit(VPoint iconBit,
- short& byte,
- short& bit);
-
- protected:
- Handle fDataHandle; // Handle to the icon's data.
- };
-
-
- // ====================================================================================
- class TZoomOutCommand : public TCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- TZoomOutCommand();
- // Constructor
-
- virtual ~TZoomOutCommand();
- // Destructor
-
- virtual void IZoomOutCommand(TIconDocument* itsIconDocument);//, TAppleEvent* theAppleEvent);
-
- virtual void DoIt(); // Override
-
- virtual void RedoIt(); // Override
-
- virtual void UndoIt(); // Override
-
- virtual TAppleEvent* MakeAppleEvent();
-
- public:
- TIconDocument* fIconDocument; // The document affected by this command.
- };
-
-
- // ====================================================================================
- class TZoomInCommand : public TCommand
- {
- MA_DECLARE_CLASS;
-
- public:
- TZoomInCommand();
- // Constructor
-
- virtual ~TZoomInCommand();
- // Destructor
-
- virtual void IZoomInCommand(TIconDocument* itsIconDocument);//, TAppleEvent* theAppleEvent);
-
- virtual void DoIt(); // Override
-
- virtual void RedoIt(); // Override
-
- virtual void UndoIt(); // Override
-
- virtual TAppleEvent* MakeAppleEvent();
-
- public:
- TIconDocument* fIconDocument; // The document affected by this command.
- };
-
- #endif
-
-
-